#include <iostream>

using std::cout;
using std::endl;

class Test
{
public:
    Test()
    {
        cout << "Test()" << endl;
    }

    ~Test()
    {
        cout << "~Test()" << endl;
    }
};

class Base
{
public:
    Base()
    {
        cout << "Base()" << endl;
    }

    Base(long base)
    : _base(base)
    {
        cout << "Base(long)" << endl;
    }

    void show() const
    {
        cout << "Base::_base = " << _base << endl;
    }

    ~Base()
    {
        cout <<"~Base()" << endl;
    }
private:
    long _base;
};

class Derived
: public Base
{
public:
    Derived(long derived)
    : Base(derived)
    , _tst()
    , _derived(derived)
    {
        cout << "Derived(long)" << endl;
    }

    void print() const
    {
        show();
        cout << "Derived::_derived = " << _derived << endl;
    }
    
    ~Derived()
    {
        cout << "~Derived()" << endl;
    }
private:
    Test _tst;//类对象数据成员
    long _derived;
};

int main(int argc, char *argv[])
{
    Derived d(10);
    d.print();
    return 0;
}

